﻿@{
    ViewBag.Title = "Sql日志";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">Sql日志列表</h3>
                <div class="box-tools">
                    <div class="input-group" style="width: 250px;">
                        <input type="text" class="form-control input-sm" placeholder="请输入名称进行模糊查询...">
                        <div class="input-group-btn">
                            <a class="btn btn-sm btn-default"><i class="fa fa-search"></i></a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-body no-padding">
                <div class="mailbox-controls">
                    <div class="btn-group" id="partial_button_toolbar">
                        @{ Html.RenderPartial("~/Areas/Common/Views/Shared/_PartialButton.cshtml"); }
                    </div>
                    <a data-toggle="tooltip" title="刷新" class="btn btn-default btn-sm"><i class="fa fa-refresh">刷新</i></a>
                </div>
                <div class="mailbox-jqgrid">
                    <table id="list"></table>
                    <div id="pager"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="detailDiv" style="overflow: auto;display: none">
    <table class="edit-table">
        <tbody>
            <tr>
                <th>
                    登录名：
                </th>
                <td>
                    <label id="CreateUserCode" />
                </td>
            </tr>
            <tr>
                <th>
                    真实姓名：
                </th>
                <td>
                    <label id="CreateUserName" />
                </td>
            </tr>
            <tr>
                <th>
                    执行时间(起)：
                </th>
                <td>
                    <label id="CreateTime" />
                </td>
            </tr>
            <tr>
                <th>
                    执行时间(止)：
                </th>
                <td>
                    <label id="EndDateTime" />
                </td>
            </tr>
            <tr>
                <th>
                    耗时(秒)：
                </th>
                <td>
                    <label id="ElapsedTime" />
                </td>
            </tr>
            <tr>
                <th valign="top">
                    Sql语句：
                </th>
                <td>
                    <label id="OperateSql" />
                </td>
            </tr>
            <tr>
                <th>
                    参数：
                </th>
                <td>
                    <label id="Parameter" />
                </td>
            </tr>
        </tbody>
    </table>
</div>
<script type="text/javascript">
    var $grid,
        height;

    function initGird() {
        $grid = $("#list").jgridview(
        {
            loadonce: false,
            url: '/System/Log/GetPagingSqlLog',
            colModel: [
                { name: "SqlLogId", hidden: true },
                { label: "登录名", name: "CreateUserCode", width: 130, fixed: true },
                { label: "真实姓名", name: "CreateUserName", width: 130, fixed: true },
                { label: "执行时间(起)", name: "CreateTime", align: "center", width: 130, formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, formatter: 'date' },
                { label: "执行时间(止)", name: "EndDateTime", align: "center", width: 130, formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, formatter: 'date' },
                { label: "耗时【秒】", name: "ElapsedTime", width: 350 }
            ],
            sortname: "CreateTime",
            height: height,
            sortorder: "desc",
            subGrid: true,
            subGridRowExpanded: function (subgridId, rowId) {
                var rowDatas = $grid.jqGrid('getRowData', rowId);
                if (typeof (rowDatas["SqlLogId"]) != "undefined") {
                    UtilAjaxPost("/System/Log/GetSqlLogById", { id: rowDatas["SqlLogId"] },
                        function (val) {
                            $("#detailDiv").find('label').each(function () {
                                var $this = $(this), id = $this.attr('id');
                                (val[id]) && $this.text(val[id]);
                            });
                        }
                    );
                } else {
                    $("#detailDiv label").html("");
                }
                $("#" + subgridId).html($("#detailDiv").html());
            }
        });
    }
   
    $(function () {
        height = UtilWindowHeightWidth().WinH - 319;
        initGird();
        $('#datepicker').datepicker({
            autoclose: true
        });
    });
</script>




